package com.zqs.sso.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登录
 */

@RestController
public class LoginController {

    @GetMapping("/api/user/login")
    public ResponseEntity<Response> userLogin(
            @RequestParam(value = "usr", required = true) String username,
            @RequestParam(value = "pwd", required = true) String password) {

        if (username == null || username.isEmpty()) {
            return ResponseEntity
                    .badRequest()
                    .body(Response.error("用户名不能为空"));
        }

        if (password == null || password.isEmpty()) {
            return ResponseEntity
                    .badRequest()
                    .body(Response.error("密码不能为空"));
        }

        return ResponseEntity.ok(Response.success("登录成功"));
    }
}
